﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;

/// <summary>
/// Summary description for SoLienLacDienTu
/// </summary>
public class SoLienLacDienTu
{
    SoLienLacDataContext db = new SoLienLacDataContext();
	public SoLienLacDienTu()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public bool CheckEmail(string Email)
    {
        bool check = true;

        Regex regex = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
        if (regex.IsMatch(Email) == false)
        {
            check = false;
        }
        return check;
    }
    public bool CheckPhone(string Phone)
    {
        bool check = true;
        Regex regex = new Regex(@"^[0-9]\d*\.?[0]*$");
        //Regex regex = new Regex();
        if (regex.IsMatch(Phone) == false)
        {
            check = false;
        }
        return check;
    }
    
    public void LoadddlKhoiHoc(DropDownList ddlKhoi)
    {
        var c = from p in db.KhoiHocs select p;
        ddlKhoi.DataTextField = "TenKhoi";
        ddlKhoi.DataValueField = "MaKhoi";
        ddlKhoi.DataSource = c;
        ddlKhoi.DataBind();
    }
    public void LoadNamHoc(DropDownList ddlNam)
    {
        var c = from p in db.NamHocs select p;
        ddlNam.DataTextField = "TenNam";
        ddlNam.DataValueField = "MaNam";
        ddlNam.DataSource = c;
        ddlNam.DataBind();

    }
    public void LoadLop(DropDownList ddlLop)
    {
        var c = from p in db.LopHocs select new { p.MaLop,p.TenLop};
        ddlLop.DataTextField = "TenLop";
        ddlLop.DataValueField = "MaLop";
        ddlLop.DataSource = c;
        ddlLop.DataBind();
    }
    public void LoadddlTenAdmin(DropDownList ddlAdmin)
    {
        var c = from p in db.Admins select new {p.MaAdmin,p.TenAdmin };
        ddlAdmin.DataTextField = "TenAdmin";
        ddlAdmin.DataValueField = "MaAdmin";
        ddlAdmin.DataSource = c;
        ddlAdmin.DataBind();
    }
    public void LoadTenGV(DropDownList ddlGV)
    {
        var c = from p in db.CanBoGiaoViens select new { p.MaCanBoGV,p.TenCanBo};
        ddlGV.DataTextField = "TenCanBo";
        ddlGV.DataValueField = "MaCanBoGV";
        ddlGV.DataSource = c;
        ddlGV.DataBind();
    }
    public void LoadddlBanHoc(DropDownList ddlBan)
    {
        var c = from p in db.BanHocs select new {p.MaBan,p.TenBan };
        ddlBan.DataTextField = "TenBan";
        ddlBan.DataValueField = "MaBan";
        ddlBan.DataSource = c;
        ddlBan.DataBind();

    }

   
}
